<template>
    <f7-page>
        <f7-navbar title="指派详情" back-link="返回">
            <f7-nav-right>地图</f7-nav-right>
        </f7-navbar>
        <f7-card class="card_nav">
            <f7-card-header>
                <div class="text-left">
                    <h4>{{tradeInfo.company_name}} <img src='../../assets/img/label-v.png' class="label-v"></h4>
                    <h5 class="ng-binding">{{tradeInfo.company_province}} - {{tradeInfo.company_city}}</h5>
                </div>
                <div class="text-right">
                    <img src='../../assets/img/infor-face.png' class="infor-face">
                    <span>{{tradeInfo.demand_user_name}}</span>
                </div>
            </f7-card-header>
            <f7-card-header>
                <div class="card-left">
                    <img src='../../assets/img/pass-icon.png' class="line-icon">
                    <div class="pull-left">
                        <b>{{tradeInfo.send_city}}</b>
                        <span>{{tradeInfo.send_district}}</span>
                        <span>{{tradeInfo.time_creation|dataFmt_fmt1('MM-dd E')}}</span>
                    </div>
                </div>
                <div class="card-center">
                    <i>{{tradeInfo.amount}}吨 {{tradeInfo.category_chn}}</i>
                    <h5 class="status-bg text-orange ">￥{{tradeInfo.price_max}}元/吨</h5>
                </div>
                <div class="card-right">
                    <div class="pull-right">
                        <b>{{tradeInfo.receive_city}}</b>
                        <span>{{tradeInfo.receive_district}}</span>
                        <span>{{tradeInfo.time_arrival|dataFmt_fmt1('MM-dd E')}}</span>
                    </div>
                </div>
            </f7-card-header>
        </f7-card>

        <f7-block v-for="(item) in tradeInfo.product_categories">
            <f7-col>
                <div>
                    <div v-for="(item1) in item.product_name" class="row-wrap">
                        <p class="classification">
                            <img src='../../assets/img/label-goodsicon.png' class="label-icon-trade"> {{tradeInfo.category_chn}}
                        </p>

                        <div class="item-add">
                            <h5 class="bold text-green">{{item1.name}}</h5>
                            <!--<i>3.5吨/件</i>-->
                            <span v-for="(item2) in item1.attribute">
                                {{item2.name}}：{{item2.value}}{{item2.unit}}
                            </span>
                        </div>
                        <div class="item-fot">
                            <span>
                                运费:￥{{item.pass_price}}元/吨
                            </span>
                        </div>
                        <div class="item-fot">
                            <span class="ng-binding">已运输{{tradeInfo.tip_price}}件</span>
                        </div>
                    </div>
                </div>
            </f7-col>

            <f7-block-title>

            </f7-block-title>
        </f7-block>

        <div class="bg-white">
            <div class="list-inset">
                <h4 class="bold">
                    货物描述
                </h4>
                <h4 class="text-gray">
                    {{tradeInfo.appendix?tradeInfo.appendix:'无特殊说明'}}
                </h4>
            </div>
        </div>

        <f7-block class="single_details">
            <span class="bold">接单详情</span>
            <span class="situation text-gray" v-if="tradeInfo.time_end">已结束</span>
        </f7-block>

        <f7-block>
            <h2>指派物流</h2>
        </f7-block>

        <div class="list-passdetail" v-for="item in tradeWlInfo">
            <span class=" orderby-num text-red ">1</span>
            <ul>
                <li>
                    <img src='../../assets/img/infor-face.png' class="infor-img">
                    <h2>
                        {{item.nick_name}}

                        <span v-if="item.status=='wait_assign'">已接单</span>
                    </h2>
                </li>
            </ul>
        </div>

        <f7-block>
            <h2>抢单物流</h2>
        </f7-block>

        <f7-list>
            <div class="item-address">
                <img src="../../assets/img/landmark.png" class="landmark">
                <h2 class="text-black">提货地址</h2>
                <h5 class="text-gray1">
                    个人地址：{{tradeInfo.send_city}}{{tradeInfo.send_district}}{{tradeInfo.send_addr}}</h5>
                <h5 class="text-gray1">联系人：{{tradeInfo.send_name}} &nbsp;&nbsp;&nbsp;&nbsp;手机号：{{tradeInfo.send_phone}}
                </h5>
                <f7-icon f7="right" color="gray" class="color-gray"></f7-icon>
            </div>
            <div class="item-address">
                <img src="../../assets/img/landmark-1.png" class="landmark">
                <h2 class="text-black">收货地址</h2>
                <h5 class="text-gray1">
                    个人地址：{{tradeInfo.receive_city}}{{tradeInfo.receive_district}}{{tradeInfo.receive_addr}}</h5>
                <h5 class="text-gray1">联系人：{{tradeInfo.receive_name}} &nbsp;&nbsp;&nbsp;&nbsp;手机号：{{tradeInfo.receive_phone}}</h5>
                <f7-icon f7="right" color="gray" class="color-gray"></f7-icon>
            </div>
        </f7-list>

        <!--   -->

        <div class="z_item">
            <div>
                <!--<div>
                    <ul>
                        <li>
                            <span>提货起始时间</span>
                            <span>自确认计划 日后提货</span>
                        </li>
                    </ul>
                </div>-->

                <ul>
                    <li>
                        <span>提货截止时间</span>
                        <span class="z_item_rt" v-if="tradeInfo.time_cost">{{tradeInfo.time_cost.time_stamp|dataFmt_fmt1('MM-dd E')}}</span>
                    </li>
                    <li>
                        <span>未按时提货扣款（元/）</span>
                        <span class="z_item_rt" v-if="tradeInfo.time_cost">{{tradeInfo.time_cost.timeout_price}}</span>
                    </li>
                    <li>
                        <span>提货完成百分比不计扣款（%）</span>
                        <span class="z_item_rt" v-if="tradeInfo.time_cost">{{tradeInfo.time_cost.not_count_price}}</span>
                    </li>
                </ul>
            </div>

            <div>
                <ul>
                    <li>
                        <span>收货时间</span>
                        <span class="z_item_rt">{{tradeInfo.time_arrival|dataFmt_fmt1('MM-dd E')}}</span>
                    </li>
                </ul>
            </div>

            <div>
                <ul>
                    <li>
                        <span>付款方式</span>
                        <span class="z_item_rt">{{tradeInfo.payment_method|payMent()}}</span>
                    </li>
                    <li>
                        <span>付款类型</span>
                        <span class="z_item_rt">{{tradeInfo.payment_choice|payMent()}}</span>
                    </li>
                    <li>
                        <span>结算凭证</span>
                        <span>
                            <span class="z_item_rt" v-if="tradeInfo.freight_voucher">
                                {{tradeInfo.freight_voucher.style=='get'?'收货方':'发货方'}}
                                <span v-if="item.checked==true" v-for="item in tradeInfo.freight_voucher[tradeInfo.freight_voucher.style]">({{item.text}})</span>
                            </span>
                        </span>
                    </li>
                    <li>
                        <span>质检标准</span>
                        <span class="z_item_rt">{{tradeInfo.quality_origin|payMent()}}</span>
                    </li>

                    <li>
                        <span>运费付款方</span>
                        <span class="z_item_rt">{{tradeInfo.payment_payer |payMent()}}</span>
                    </li>

                    <li>
                        <span>运费收款方</span>
                        <span class="z_item_rt">{{tradeInfo.payment_payee|payMent()}}</span>
                    </li>
                </ul>
            </div>
        </div>

        <!--  -->

        <personalCard></personalCard>

        <companyCard :message="companyId"></companyCard>

        <f7-toolbar>
            <div class="row button-foot">
                <div class="col col-33">
                    <f7-link>立即沟通</f7-link>
                </div>
                <div class="col col-33">
                    <f7-link>打电话</f7-link>
                </div>
                <div class="col col-33">
                    <f7-link @click="poPover()" class="immediately">
                        {{$f7Route.params.statutype|tradeButton()}}
                    </f7-link>
                </div>
            </div>
        </f7-toolbar>
    </f7-page>
</template>

<script>
import F7NavLeft from 'framework7-vue/src/components/nav-left'
import companyCard from '../../components/companyCard.vue'
import personalCard from '../../components/personalCard.vue'
import F7Link from "framework7-vue/src/components/link";
import F7Button from "framework7-vue/src/components/button";
import F7Toolbar from "framework7-vue/src/components/toolbar";
import F7Popover from "framework7-vue/src/components/popover";



export default {
    name: 'tradeDemandDtl',
    data () {
        return {
            tradeInfo: '',
            tradeWlInfo: '',
            companyId: ''
        }
    },
    components: {
        F7Popover,
        F7Toolbar,
        F7Button,
        F7Link,
        F7NavLeft,
        companyCard,
        personalCard
    },
    methods: {
        async getTeadeDlt () {
            let param = { demand_id: this.$f7Route.params.tradeid }
            this.tradeInfo = (await this.LineService.tradeDetails(param)).data.data
            this.companyId = this.tradeInfo.company_id
        },
        async getTradeWl () {
            let param = { demand_id: this.$f7Route.params.tradeid }
            this.tradeWlInfo = (await this.LineService.tradeWlDetails(param)).data.data.assign
        },
        //弹框
        async poPover () {
            let driverLinePriceRes = await this.LineService.driverLinePrice({demand_id: this.$f7Route.params.tradeid})
            let price=driverLinePriceRes.data.data.demand_price
            let param = { demand_id: this.$f7Route.params.tradeid,price:price }
            let addPlancRes = await this.LineService.addPlanc(param)
            if(addPlancRes.data.status=='success'){
                this.toast('接单成功！')
                setTimeout( () =>{
                    this.$f7.router.navigate('/trade/')
                },1000)
            }else{
                this.toast(addPlancRes.data.msg)
            }


        }
    },
    mounted () {
         // console.log(this.$f7Route)
        this.getTeadeDlt()
        this.getTradeWl()
    }
}
</script>

<style scoped>
.ios .toolbar a.link {
    height: 44px;
    font-size: 14px;
    color: #999;
}
.immediately{
    color: #fff !important;
    background: #db4226  !important;
}
.row {
  width: 100%;
  background: white;
}
.button-foot .col-33 {
  width: 33.333333333333%  !important;
  align-items: center;
  justify-content: center;
  color: #666;
  text-align: center;
  border-left: 1px solid #f5f5f5;
}

.z_item ul {
  padding-left: 0;
  font: inherit;
  font-size: 100%;
  font-family: '微软雅黑';
  color: #444;
}
.z_item li {
  background: white;
  padding-left: 10px;
  border-bottom: 1px solid #f5f5f5;
  line-height: 40px;
  font-weight: bold;
}
.z_item .z_item_rt {
  float: right;
  margin-right: 10px;
  color: #ff6c00;
  font-weight: normal;
}

.ios .list {
  margin: 20px 0px 0px 0px;
  background: #fff;
}

.item-address {
  position: relative;
  border: none;
  padding: 10px 0 8px 50px;
  min-height: 0;
  border-bottom: 1px solid #f5f5f5;
}

.item-address h2 {
  color: #333;
  font-size: 14px;
  margin: 0;
}

.item-address h5 {
  color: #333;
  font-size: 12px;
  margin: 0;
}

.landmark {
  position: absolute;
  border-radius: 0;
  width: 21px;
  height: 30px;
  left: 15px;
  top: 12px;
}

.color-gray {
  position: absolute;
  top: 30px;
  color: #8e8e93;
  font-size: 20px;
  right: 10px;
}

.ios .navbar {
  font-size: 16px;
}

.ios .navbar .right {
  margin-left: 10px;
  color: #fff;
  font-size: 14px;
}

.ios .card-header {
  padding: 4px 15px;
  min-height: 55px;
  position: static;
}

.text-right {
  text-align: center;
}

.infor-face {
  max-width: 24px;
  max-height: 24px;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.text-right span {
  margin: 0 0 3px 0;
  font-size: 10px;
  color: #999;
  display: inherit;
}

.text-left h4 {
  font-size: 14px;
  padding-right: 15px;
  margin-bottom: 0;
  font-weight: bold;
  color: #333;
}

.label-v {
  width: 24px;
  height: 14px;
  vertical-align: text-bottom;
  vertical-align: middle;
}

.text-left h5 {
  color: #999;
  font-size: 12px;
  padding-right: 15px;
  font-weight: initial;
  margin-top: 3px;
}

.line-icon {
  position: absolute;
  left: 16px;
  width: 16px;
  height: 45px;
}

.pull-left {
  text-align: left;
  margin-left: 24px;
}

.pull-left b {
  font-size: 14px;
  color: #000;
  display: block;
}

.pull-left span {
  font-size: 12px;
  color: #666;
  display: block;
  width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-center i {
  font-style: normal;
  color: #333;
  font-size: 12px;
  text-align: center;
  display: inherit;
}

.text-orange {
  color: #ff6c00;
  font-weight: normal !important;
  font-size: 13px;
  text-align: center;
}

.status-bg {
  background: url('../../assets/img/route-bg.png') no-repeat top center;
  background-size: 95px 4px;
  margin-top: 6px;
  padding-top: 10px;
  width: 97px;
}

.card-right {
  text-align: center;
}

.pull-right {
  text-align: right;
}

.pull-right b {
  font-size: 14px;
  color: #000;
  display: block;
}

.pull-right span {
  margin: 0 0 3px 0;
  font-size: 10px;
  color: #999;
  display: inherit;
  width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ios .block {
  margin: 0;
  padding: 15px 0px 15px 15px;
  background: #fff;
}

.classification {
  height: 21px;
  color: #333;
  font-size: 14px;
  margin: 0px;
}

.label-icon-trade {
  width: 32px;
  height: 16px;
  margin-right: 18px;
  margin-top: 2px;
  float: left;
}
.row-wrap {
  padding: 10px 0px;
  border-bottom: 1px solid #f5f5f5;
}
.item-add {
  background: #f8fff0;
  padding: 4px 10px;
  margin: 10px 0px;
  border-left: 1px solid green;
}

.item-add span {
  width: 50%;
  color: rgb(51, 140, 37);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

.item-fot span i {
  color: #ff6c00;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
  font-weight: initial;
}

.item-add h5 {
  margin: 5px 0px;
}

.item-fot span {
  font-size: 13px;
  color: #666;
}

.ios .block-title {
  margin: 10px 0px 0px 0px;
}

.ng-binding {
  margin-right: 10px;
}

.bg-white {
  background: #fff;
  padding: 10px 0px;
}

.list-inset {
  margin: 0 15px;
}

.list-inset .bold {
  margin: 10px 0px;
  color: #000;
}

.text-gray {
  margin: 0;
  color: #999;
  font-size: 14px;
}

.bold {
  font-weight: bold;
  font-size: 14px;
}

.single_details {
  margin: 20px 0px 0px 0px !important;
  padding: 15px !important;
  border-bottom: 1px solid #f5f5f5;
}

.situation {
  float: right;
}

.ios .block h2 {
  color: #000;
  font-weight: bold;
  font-size: 14px;
}

.text-red {
  font-weight: bold;
  color: #db4226;
  font-size: 14px;
}
.text-green {
    color: rgb(51, 140, 37);
}
.list-passdetail {
  position: relative;
  padding: 5px 0 5px 30px;
  background: #fff;
  border-bottom: 1px solid #f5f5f5;
}

.orderby-num {
  position: absolute;
  left: 15px;
  top: 20px;
  font-size: 18px !important;
  z-index: 99;
}

.infor-img {
  position: absolute;
  left: 50px;
  width: 40px;
  height: 40px;
  vertical-align: text-bottom;
  vertical-align: middle;
  border-radius: 100%;
  background: #f0f0f0;
  top:13px;
}

.list-passdetail ul {
  padding: 0;
}

.list-passdetail ul li {
  list-style: none;
  padding:5px 15px;
}

.list-passdetail ul li span {
  float: right;
}

.list-passdetail h2 {
  color: #333;
  font-size: 14px;
  font-weight: initial;
  padding-left: 60px;
}

.button-small {
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 2px 4px 1px;
  width: 60px;
  height: 30px !important;
  line-height: 30px !important;
  background: #db4226;
  color: #fff !important;
  border: none !important;
  font-weight: initial !important;
  font-size: 12px !important;
}
.card_nav {
  padding: 10px 0px;
  border-radius: 0px !important;
  margin: 0px !important;
}
</style>
